package cn.cqie.frame.mapper;

import cn.cqie.frame.entity.SysMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author XYHL
 * @since 2021-09-08
 */
public interface SysMenuMapper extends BaseMapper<SysMenu> {



    @Select("SELECT DISTINCT sys_menu.id, name,path,component,icon,is_hidden,parentId,sortCode FROM user_role \n" +
            "            JOIN role_menu  ON user_role.roleId = role_menu.role_id\n" +
            "            JOIN sys_menu ON role_menu.menu_id = sys_menu.id\n" +
            "WHERE userId=#{userId} ")
    /**
     * 根据用户id查询菜单
     * @param userInfoId 用户信息id
     * @return 菜单列表
     */
    List<SysMenu> listMenusByUserId(Long userId);
}
